extension FunctionalX<T> on T {
  R let<R>(R Function(T it) block) => block(this);

  T also(Function(T it) block) {
    block(this);

    return this;
  }
}

extension NullableListX<T> on List<T>? {
  bool get isNullOrEmpty {
    if (this == null) return true;
    return this!.isEmpty;
  }
}

extension ListX<T> on List<T> {
  void addIfNotExist(T t, {bool Function(T)? predicate}) {
    if (predicate != null) {
      if (any(predicate)) return;
    } else {
      if (contains(t)) return;
    }
    add(t);
  }
}
extension NullableMapX<K,V> on Map<K,V>? {
  bool get isNullOrEmpty {
    if (this == null) return true;
    return this!.isEmpty;
  }
}